import { Router, Route, Redirect, Switch } from "react-router-dom"
import Login from "@/pages/login"
import Layout from "@/pages/layout"
import ProfileEdit from "./pages/profile/edit"
import { customHistory } from "./utils/history"
import AuthRoute from "./components/AuthRoute"
import Article from "./pages/Article"
import Chat from "./pages/Chat"
import "@/App.scss"

const App = () => {
  return (
    <Router history={customHistory}>
      <div className="app">
        <Switch>
          {/* 默认展示首页内容 */}
          <Route path="/" exact render={() => <Redirect to="/home/index" />}></Route>
          <Route path="/home" component={Layout}></Route>
          <Route path="/login" component={Login}></Route>
          <Route path="/article/:id" component={Article}></Route>

          <AuthRoute path="/profile/edit">
            <ProfileEdit />
          </AuthRoute>
          <AuthRoute path="/chat">
            <Chat />
          </AuthRoute>
        </Switch>
      </div>
    </Router>
  )
}
export default App
